<template>
  <div class="main">
    <el-form ref="form"
             class="login"
             label-width="80px">
      <el-form-item>
        商品管理系统
      </el-form-item>
      <el-form-item label="账号">
        <el-input v-model="form.userName"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password"
                  type="password"></el-input>
      </el-form-item>
      <el-form-item class="ln">
        <el-button class="bn"
                   type="primary"
                   @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data () {
    return {
      form: {}
    }
  },
  methods: {
    login () {
      //res.data.data.token
      this.axios.post('/admin/login', this.form).then(res => {
        if (res.code === '2000') {
          localStorage.setItem("token", res.data);
          this.$router.push('/')
        }
      })
    }
  }

}
</script>

<style lang="less" scoped>
.main {
  height: 100vh;
  display: flex;
  align-items: center;
}
.login {
  width: 25%;
  margin: 0px auto;
  height: 40vh;
  padding-right: 80px;
  border: 1px solid rgb(235, 235, 235);
  background: rgb(255, 255, 255);
}
.ln {
  text-align: center;
  .bn {
    width: 100px;
  }
}
</style>